package com.edu.exam.enums.academic;

/**
 * 学制系统枚举
 */
public enum AcademicSystem {
    SEMESTER("SEMESTER", "学期制"),
    QUARTER("QUARTER", "学季制"),
    TRIMESTER("TRIMESTER", "三学期制"),
    YEAR("YEAR", "学年制");

    private final String code;
    private final String description;

    AcademicSystem(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     * @throws IllegalArgumentException 如果代码无效
     */
    public static AcademicSystem fromCode(String code) {
        for (AcademicSystem system : values()) {
            if (system.getCode().equals(code)) {
                return system;
            }
        }
        throw new IllegalArgumentException("Unknown AcademicSystem code: " + code);
    }

    @Override
    public String toString() {
        return description;
    }
}